#include<iostream>
#include<cmath>
using namespace std;
const int N = 2e6 + 10;
int l[N], r[N];
int ll[N], rr[N]; // 分别记录副坐标和正坐标的矿的前缀和数组
int n, m;
int M,ans;
int main()
{
	cin >> n >> m;
	for (int i = 1;i <= n;i++)
	{
		int x = 0;
		cin >> x;
		if (x >= 0) r[x]++;
		else l[abs(x)]++;
		M = max(M, abs(x));
	}
	if (r[0] != 0) rr[0] = 1;//特殊处理
	//构建前缀和数组
	for (int i = 1;i <= M;i++)
	{
		ll[i] = ll[i - 1] + l[i];
		rr[i] = rr[i - 1] + r[i];
	}
	//模拟走路
	
	for (int i = 0;i <= m;i++)
	{
		int ret = 0;
		//i为向右走的距离
		//当i等于0是就相当于全向左走了
		ret += rr[i];
		if (m - 2 * i > 0) ret += ll[m - 2 * i];
		ans = max(ans, ret);
	}
	//也可以先向左走
	for (int i = 1;i <= m;i++)
	{
		int ret = 0;
		ret += ll[i];
		if (m - 2 * i >= 0) ret += rr[m - 2 * i];
		ans = max(ans, ret);
	}
	cout << ans << endl;
	return 0;
}